package com.xing.gc;

import com.xing.annotation.Component;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Author: ljx
 * @Date: 2021-11-21 15:34
 */
public class GcMain2Test {

    public static void main(String[] args) throws Exception{
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

        executorService.scheduleAtFixedRate(MemLeaker::run, 10, 1, TimeUnit.SECONDS);

        System.in.read();
    }

    public static class MemLeaker {
        private static List<Object> objs = new LinkedList<>();

        public static void run() {
            for (int i = 0; i < 50000; i++) {
                objs.add(new Object());
            }
        }

    }
}
